import SwiftUI
import SPGlassKit

public struct GlassPopoverExample: GlassExample {
    public static let componentID = "glass-popover"
    @State private var showsDetails = false
    @State private var showsHelp = false

    public init() {}

    public var body: some View {
        HStack(spacing: 24) {
            GlassIconButton(systemImage: "info", accessibilityLabel: "Price details") { showsDetails = true }
                .glassPopover(isPresented: $showsDetails, title: "Price details", arrowEdge: .top, compactAdaptation: .popover) {
                    Text("Sample price, taxes included.")
                        .padding()
                        .frame(minWidth: 220, alignment: .leading)
                }
            GlassButton("Help", systemImage: "questionmark.circle") { showsHelp = true }
                .glassPopover(isPresented: $showsHelp, title: "Help", compactAdaptation: .sheet) {
                    Text("On a compact width this popover becomes a sheet with a close button.")
                        .padding()
                        .frame(maxWidth: .infinity, alignment: .leading)
                }
        }
        .padding()
    }
}

#Preview("GlassPopover") { GlassPopoverExample() }
